package com.yuting.practice.letcode;

public class zuixiaoercimi {


    public int getzuixiaoercimi(int n){
//        n = n - 1;

        n |= n >>> 1;
        n |= n >>> 2;
        n |= n >>> 4;
        n |= n >>> 8;
        n |= n >>> 16;
        return n+1;
    }

    public int getzuidaercimi(int n){
        n = n-1;
        n |= n >>> 1;
        n |= n >>> 2;
        n |= n >>> 4;
        n |= n >>> 8;
        n |= n >>> 16;
        n = n >>> 1;
        return n+1;
    }

    public static void main(String[] args) {
       zuixiaoercimi z = new zuixiaoercimi();

        System.out.println(z.getzuixiaoercimi(4));

        System.out.println(z.getzuidaercimi(4));
    }

}
